﻿using System;


class QuickSort
{
    public static void Quicksort(string[] elements, int left, int right)
    {

        string pivot = elements[(left + right) / 2];

        while (left <= right)
        {
            while (elements[left].CompareTo(pivot) < 0)
            {
                left++;
            }
            while (elements[right].CompareTo(pivot) > 0)
            {
                right--;
            }
            if (left <= right)
            {
                string temp = elements[left];
                elements[left] = elements[right];
                elements[right] = temp;
                left++;
                right--;
            }
        }
        if (left < right)
        {
            Quicksort(elements, left, right);
        }
        if (left < right)
        {
            Quicksort(elements, left, right);
        }

    }
    static void Main(string[] args)
    {
        string[] arrUnsorted = { "z", "e", "x", "c", "m", "q", "a" };

        for (int i = 0; i < arrUnsorted.Length; i++)
        {
            Console.Write("{0} ", arrUnsorted[i]);
        }
        Console.WriteLine();

        Quicksort(arrUnsorted, 0, arrUnsorted.Length - 1);
        for (int i = 0; i < arrUnsorted.Length; i++)
        {
            Console.Write("{0} ", arrUnsorted[i]);
        }
        Console.WriteLine();
    }
}

